import random
from selenium.webdriver.common.by import By
import datetime
from conftest import BASE_DIR

#TODO """****************以下为登录页面元素配置信息*******************"""
# 登录链接
login_link = By.PARTIAL_LINK_TEXT, "登录"
# 用户名
login_username = By.ID, "username"
# 密码
login_pwd = By.ID, "password"
# 验证码
login_verify_code = By.ID, "verify_code"
# 登录按钮
login_btn = By.CSS_SELECTOR, ".J-login-submit"
# 获取异常文本信息
login_err_info = By.CSS_SELECTOR, ".layui-layer-content"
# 点击异常提示框 按钮
login_err_btn_ok = By.CSS_SELECTOR, ".layui-layer-btn0"


# TODO """****************以下为商城首页配置数据*******************"""
#进入我的购物车链接
into_cart=By.CSS_SELECTOR, 'div[class="c-n fl"] span'
#搜索框
search_info=By.ID, 'q'
#搜索按钮
search_btn=By.CLASS_NAME, 'ecsc-search-button'
#商品信息
search_goods_info=By.XPATH,'/html/body/div[4]/div/div[2]/div[2]/ul/li/div/div[4]/a'



#TODO """****************以下为个人中心配置数据*******************"""
#返回商城首页链接
return_shop_link=By.PARTIAL_LINK_TEXT, "返回商城首页"
#登录用户名
user_name=By.CLASS_NAME, 'mu-m-vip'
#点击个人信息链接
into_user_info=By.LINK_TEXT, '个人信息'
#编辑个人头像
edit_head_pic=By.ID, 'preview'
#上传图像
upload_image=By.NAME, 'file'
#图片路径
# filepath=BASE_DIR + r"/image/1.jpg"
#定位iframe
iframe_loc=By.ID, 'layui-layer-iframe1'
#定位上传成功
upload_success=By.CLASS_NAME, 'success'
#点击 确定使用
confirm_use=By.CLASS_NAME, 'saveBtn'
#选择性别
sex=["woman","man","secret"]
edit_sex=(By.ID, '{}'.format(random.choice(sex)))
#便捷生日
edit_birthday=By.ID, 'birthday'
birthday=datetime.datetime.now().strftime('%Y-%m-%d')   #如2023-10-22
#点击确认保持按钮
save_btn=By.CLASS_NAME, 'save'
#编辑昵称
edit_nickname=By.ID, 'nickname'
nickname="昵称_{}".format(random.randint(1,99))
#TODO  ******  地址管理
#地址管理菜单
address_manage=By.LINK_TEXT, '地址管理'
#增加新地址按钮
add_new_address=By.CLASS_NAME, 'co_blue'
#地址管理中的iframe框架
iframe2_loc=By.CSS_SELECTOR, 'div[class="layui-layer-content"] iframe'
#收货人
receiver=By.NAME, 'consignee'
receiver_value='吴少凡'
#下拉框-省
province=By.ID, 'province'
#province_option='{}'.format(random.randint(1,34))
province_option='10'
#下拉框-市
# city=By.ID, 'city'
# city_option=By.XPATH,  '//*[@id="city"]/option[{}]'.format(random.randint(1,10))
city_option=By.XPATH,  '//*[@id="city"]/option[2]'
#下拉框-区
# district=By.XPATH,  '//*[@id="district"]/option[{}]'.format(random.randint(3,10))
district=By.XPATH,  '//*[@id="district"]/option[6]'
#下拉框-镇
# twon=By.XPATH,  '//*[@id="twon"]/option[{}]'.format(random.randint(1,10))
twon=By.XPATH,  '//*[@id="twon"]/option[7]'
#详细地址
detail_address=By.ID, 'address'
detail_address_value='莲花北苑3栋205室'
#邮政编码
zipcode=By.NAME, 'zipcode'
zipcode_value='123456'
#手机号
phone=By.NAME, 'mobile'
phone_value='18325531234'
#保存收货地址按钮
save_new_addr_btn=By.CSS_SELECTOR, 'button[type="submit"] span'
#删除地址按钮
delete_addr_btn=By.LINK_TEXT, '删除'

#TODO """****************以下为商品详情配置数据*******************"""
#商品详情中商品价格
goods_price=By.ID, 'goods_price'
#数量加号按钮
add_one=By.CLASS_NAME, 'add'
#加入购物车按钮
add_cart=By.ID, 'join_cart'
#加入购物车成功提示框
close_normal_alert= By.CSS_SELECTOR, '.layui-layer-ico.layui-layer-close.layui-layer-close1'
#"我的购物车"链接
my_cart=By.CSS_SELECTOR, "div[class='c-n fl'] span"


#TODO """****************以下为我的购物车配置数据*******************"""
#商品总价格
goods_total_price=By.ID, 'cart_46_market_price'
#清空按钮
clear_btn=By.CSS_SELECTOR, 'td[align="center"] a[class="gwc-gb deleteGoods"]'
#商品名称文本
goods_name=By.CSS_SELECTOR, 'p[class="gwc-ys-pp"] a'
#返回首页链接
home_btn=By.CSS_SELECTOR, 'p[class="shopcar_empty"] img'
#退出链接
logout_btn=By.PARTIAL_LINK_TEXT, "退出"